<?php
namespace app\index\controller;
use think\Db;
use app\index\controller\Base;
class Cla extends Base
{
    public function addClass()
    {
        $data = input('post.');

        $arr = ['name'=>$data['className'],'describe'=>$data['classDescribe']];
        $res = Db::name('class')->insert($arr);
        if ($res){
            $this->success('添加成功','index/User/addClass');
        }else{
            $this->error('添加失败');
        }
    }
    public function classPerson()
    {
        @$data = input('get.');
        $result = Db::name('classperson')->alias('a')->join('person b','a.person_id=b.person_id','RIGHT')->where('a.class_id',$data['class_id'])->select();
        $this->assign('result',$result);
        $this->assign('class_id',$data['class_id']);
        return $this->fetch('user/classPerson');
    }
    public function personStatus()
    {
        $data = input('get.');
        if ($data['status']==0){
           $res =  Db::name('person')->data(['status'=>1])->where('person_id',$data['person_id'])->update();
        }
        if ($data['status']==1){
           $res =  Db::name('person')->data(['status'=>0])->where('person_id',$data['person_id'])->update();
        }
        if ($res){
            $this->success('修改成功');
        }
    }
}